﻿using System;
using System.Data.Entity;
using System.Collections.Generic;
using IEstate.Core.Models;
using IEstate.Repositories;

namespace IEstate.Repositories.Database
{
    public class EstateInitializer : DropCreateDatabaseAlways<EstateContext>
    {
        protected override void Seed(EstateContext DBContext)
        {
            DateTime _date = new DateTime(2014, 9, 6, 13, 45, 0);
            DateTime date = new DateTime(2014, 9, 10, 16, 0, 0);
            var Estates = new List<Estate>
            {
                new Estate { Street = "Avram Iancu", City = "Cluj", TypeOption = Option.buy, TypeCategory = Category.apartment, Price = 50M, Size = 63.5M, Bedrooms = 3, UID = 3, Date = DateTime.Now },
                new Estate { Street = "Calea Dorobantilor", City = "Cluj", TypeOption = Option.rent, TypeCategory = Category.studio, Price = 65M, Size = 70M, Bedrooms = 4, UID = Global.Count, Date = DateTime.Now },
                new Estate { Street = "Bulevardul Eroilor", City = "Deva", TypeOption = Option.rent, TypeCategory = Category.apartment, Price = 70M, Size = 60M, Bedrooms = 2, UID = 4, Date = DateTime.Now },
                new Estate { Street = "Ardealul", City = "Bacau", TypeOption = Option.buy, TypeCategory = Category.studio, Price = 35, Size = 32.5M, Bedrooms = 1, UID = Global.Count, Date = DateTime.Now },
                new Estate { Street = "Bucovina", City = "Bacau", TypeOption = Option.buy, TypeCategory = Category.apartment, Price = 27, Size = 36.7M, Bedrooms = 1, UID = 4, Date = DateTime.Now },
                new Estate { Street = "Horea", City = "Bacau", TypeOption = Option.buy, TypeCategory = Category.house, Price = 95M, Size = 80M, Bedrooms = 4, UID = 5, Date = DateTime.Now, Promotional = true },
                new Estate { Street = "Milcoveni", City = "Deva", TypeOption = Option.rent, TypeCategory = Category.house, Price = 70M, Size = 70M, Bedrooms = 5, UID = 5, Date = _date },
                new Estate { Street = "Stefan cel Mare", City = "Brasov", TypeOption = Option.rent, TypeCategory = Category.villa, Price = 65M, Size = 53.5M, Bedrooms = 3, UID = 2, Date = _date },
                new Estate { Street = "Venus", City = "Brasov", TypeOption = Option.buy, TypeCategory = Category.villa, Price = 115M, Size = 83.5M, Date = date, Bedrooms = 5, Promotional = true },
                new Estate { Street = "Baciu", City = "Cluj", TypeOption = Option.buy, TypeCategory = Category.house, Price = 130M, Size = 96.5M, Promotional = true, Bedrooms = 6, Date = date },
                new Estate { Street = "Bucuresti", City = "Cluj", TypeOption = Option.buy, TypeCategory = Category.studio, Price = 25M, Size = 29.7M, Bedrooms = 1, Date = DateTime.Now }
            };

            Global.Count = 7;

            Estates.ForEach(p => DBContext.Estates.Add(p));
            DBContext.SaveChanges();
        }
    }
}
